package com.hsjk.szwj.module.system.controller.app.tenant;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.framework.security.core.annotations.PreAuthenticated;
import com.hsjk.szwj.module.system.controller.app.tenant.vo.TenantInfoRespVO;
import com.hsjk.szwj.module.system.service.tenant.TenantService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/09/09 22:09
 **/
@Tag(name = "应用端 - 租户")
@RestController
@RequestMapping("/system/tenant")
public class TenantController {
    @Resource
    private TenantService tenantService;

    @GetMapping("/get-tenant-id-by-domain")
    @Operation(summary = "根据域名获取租户id")
    public CommonResult<Long> getTenantIdByDomain(@RequestParam String domain){
        return success(tenantService.getTenantIdByDomain(domain));
    }

    @GetMapping("/get-tenant-info")
    @Operation(summary = "获得当前租户基础信息")
    public CommonResult<TenantInfoRespVO> getTenantInfo() {
        return success(tenantService.getCurrentInfo());
    }
}
